<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('服务商尾款充值抵扣列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                服务商编号：
                                <input type="text" name="agentNum"/>
                            </li>
                            <li>
                                服务商名称：
                                <input type="text" name="agentName"/>
                            </li>
                            <li>
                                申请状态：
                                <select name="applyStatus">
                                    <option value="">所有</option>
                                    <option value="0"> 处理中</option>
                                    <option value="1"> 同意</option>
                                    <option value="2"> 拒绝</option>
                                    <option value="3"> 作废</option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="add()" shiro:hasPermission="AgentApplyTailmoney:AgentApplyTailmoney:add">
                    <i class="fa fa-plus"></i> 添加尾款充值申请
                </a>
             <!--   <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="AgentApplyTailmoney:AgentApplyTailmoney:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="AgentApplyTailmoney:AgentApplyTailmoney:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="AgentApplyTailmoney:AgentApplyTailmoney:export">
                    <i class="fa fa-download"></i> 导出
                </a>-->
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('AgentApplyTailmoney:AgentApplyTailmoney:edit')}]];
        var removeFlag = [[${@permission.hasPermi('AgentApplyTailmoney:AgentApplyTailmoney:remove')}]];
        var prefix = ctx + "AgentApplyTailmoney/AgentApplyTailmoney";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "服务商尾款充值抵扣",
                columns: [
                {
                    field: 'agentNum',
                    title: '提交申请服务商编号'
                },
                {
                    field: 'agentName',
                    title: '提交申请服务商名称'
                },
                {
                    field: 'applyMoney',
                    title: '申请充值金额'
                },
                {
                    field: 'applyStatus',
                    title: '申请状态',
                    formatter(value,row,index){
                        if (value == '0'){
                            return '处理中';
                        } else if (value == '1'){
                            return '同意';
                        } else if (value == '2'){
                            return '拒绝';
                        } else if (value == '3'){
                            return '作废';
                        }
                    }
                },
                {
                    field: 'applyDate',
                    title: '申请日期'
                },
                {
                    field: 'applyTime',
                    title: '申请时间'
                },
                {
                    field: 'financeDate',
                    title: '审核日期'
                },
                {
                    field: 'financeTime',
                    title: '审核时间'
                },
                {
                    field: 'surplusMoney',
                    title: '当前剩余尾款'
                },
                {
                    field: 'addMan',
                    title: '添加人'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if (row.applyStatus == '0'){
                            actions.push('<a class="btn btn-danger btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="zf(\'' + row.id + '\')"><i class="fa fa-remove"></i>作废</a>');
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>审核</a> ');
                        }

                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });


        /**
         * 作废
         * @param id
         */
      function zf(id) {
           var agentNum = $.table.selectColumns("agentNum");
           $.modal.confirm("确定作废当前信息吗？", function() {
               $.operate.save(prefix + "/edit", {"applyStatus":"3","id":id});
           });
       }

        /**
         * 审核
         * @param id
         */
       function auditView(id) {
            $.modal.open("审核尾款",prefix + "/auditView?id=" + id,1000,800);
        }


        /**
         * 充值
         */
        function add() {
            $.modal.open("尾款充值",prefix + "/add",800,400);
        }



    </script>
</body>
</html>